package permission.role;

import permission.Secureable;

public class OwnerRole implements Role {
	
	private final RoleType ROLE = RoleType.OWNER;
	private final Secureable OBJECT;
	
	public OwnerRole(Secureable object) {
		this.OBJECT = object;
	}
	
	@Override
	public RoleType getRoleType() {
		return ROLE;
	}
	
	public Secureable getObjectOfOwnerShip() {
		return OBJECT;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((OBJECT == null) ? 0 : OBJECT.hashCode());
		result = prime * result + ((ROLE == null) ? 0 : ROLE.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		OwnerRole other = (OwnerRole) obj;
		if (OBJECT == null) {
			if (other.OBJECT != null) {
				return false;
			}
		} else if (!OBJECT.equals(other.OBJECT)) {
			return false;
		}
		if (ROLE != other.ROLE) {
			return false;
		}
		return true;
	}
}
